<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>

<!--引入外部文件-->
<script src="./node_modules/vue/dist/vue.js" ></script>

<body>

<div id="app">
    <input type="button" value="跑起来" @click="lang()">
    <input type="button" value="咋瓦鲁多" @click="stop()">
    <br>
    {{msg}}
</div>

</body>
<script>

    let vm = new Vue({
        el:"#app",
        data:{
            msg:"我是一位帅气高冷富有强壮可爱的男人",
            id:null
        },
        methods:{
            lang(){
                this.id = setInterval(() => {
                    var start = this.msg.substring(0,1);
                    // 从第2个切到最后
                    var end = this.msg.substring(1);
                    this.msg = end + start;
                },400)
            },
            stop(){
                clearInterval(this.id)
            }
        },
        // 这里为什么是一个方法
        beforeCreate(){
            console.log("beforeCreate")
        },
        created(){
            console.log("created")
        },
        beforeMount(){
            console.log("beforeMount")
        },
        mounted(){
            console.log("mounted")
        },
        beforeUpdate(){
            console.log("beforeUpdate")
        },
        beforeDestroy(){
            console.log("beforeDestroy")
        },
        destroyed(){
            console.log("destroyed")
        }

    })

</script>
</html>